// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import VueResource from 'vue-resource'
import bindmoment from "./libs/tools";
import MuseUi from 'muse-ui'
import 'muse-ui/dist/muse-ui.css'
import './assets/js/font_size.js'
import './assets/style/common.css'
import './assets/style/z_style.css'
import './assets/font/iconfont.css';


import VueCookies from 'vue-cookies';
import './assets/js/ios_touchend.js';
import 'vue2-toast/lib/toast.css';
import echarts from 'echarts'
import Toast from 'vue2-toast';
import 'mint-ui/lib/style.css';
Vue.use(Toast);
Vue.use(MuseUi)
Vue.use(VueCookies)
Vue.use(bindmoment)
Vue.use(VueResource)

Vue.prototype.$echarts = echarts

Vue.config.productionTip = false;
router.beforeEach((to, from, next) => {
  if(to.query.token&&to.query.localUrl&&to.query.AUTTYPE){
    sessionStorage.setItem("token",to.query.token);
    sessionStorage.setItem("localUrl",to.query.localUrl);
    sessionStorage.setItem("AUTTYPE",to.query.AUTTYPE);

  }
  // if(sessionStorage.getItem('type')!=''&&sessionStorage.getItem('type')!=null){
  //   var turnRoute = "/" + sessionStorage.getItem('type')
  //   sessionStorage.setItem('type','')
  //   router.push({path:turnRoute});
  // }
  // console.log(sessionStorage.getItem('type'))

//	var req = new XMLHttpRequest();
//	req.open('GET', document.location, false);
//	req.send(null);
//	var headers = req.getAllResponseHeaders().toLowerCase();
//	alert(headers);
//	console.log(to)
	next()
//	console.log(Vue.http)
});

Vue.http.interceptors.push((request, next) => {
  if(router.currentRoute.query.token&&router.currentRoute.query.localUrl&&router.currentRoute.query.AUTTYPE){
    sessionStorage.setItem("token",router.currentRoute.query.token);
    sessionStorage.setItem("localUrl",router.currentRoute.query.localUrl);
    sessionStorage.setItem("AUTTYPE",router.currentRoute.query.AUTTYPE);


  }
    const tokenVal = sessionStorage.getItem('token');
    const autType = sessionStorage.getItem('AUTTYPE');
		if(tokenVal) {
      request.headers.set("USERTOKEN",tokenVal)
      // request.headers.set("AUTTYPE",'DISPATCH')
      request.headers.set("AUTTYPE",'SELLER')

      
     }
     if(autType) {
      request.headers.set("AUTTYPE",autType)
     }
　　next((response) => {
	
	});
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: { App },
  template: '<App/>'
})
